package com.yr.ryjk.test.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import com.yr.ryjk.test.entity.Question;

public interface QuestionMapper {
    int deleteByPrimaryKey(String id);

    int insert(Question record);

    int insertSelective(Question record);

    Question selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(Question record);
    int updateByPrimaryKeySelective2(Question record);

    int updateByPrimaryKey(Question record);

    @Select("select * from question where test_id=#{2} limit #{0},#{1}")
    @ResultMap("BaseResultMap")
	List<Question> selectOfPageAndType(int start, int pageSize, String testId);

    @Select("select count(1) from question where test_id=#{0}")
    @ResultType(Integer.class)
	int selectCountOfType(String testId);

    @Select("select IFNULL(sum(score),0) from question where test_id=#{0}")
	int selectTotalScore(String testId);

    @Select("select * from question where id=#{0}")
    @ResultMap("BaseResultMap")
	Question selectQuestionById(String id);

    @Delete("delete from question where find_in_set(id,#{0})")
	void deleteByIds(String ids);

    @Select("select * from question where test_id=#{0}")
    @ResultMap("BaseResultMap")
	List<Question> selectQuestionOfType(String testId);

    @Delete("delete from question where test_id=#{0}")
	void deleteByTestId(String id);
}